package com.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


@SuppressWarnings({"all"})
/**
 * 此类为连接工厂创建信道的工具类
 */
public class RabbitMqUtils {

    // 得到一个连接的channel
    public static Channel getChannel() throws  Exception {
        // 创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("62.234.33.229");
        factory.setVirtualHost("/");
        factory.setUsername("admin");
        factory.setPassword("123");
        Connection connection = factory.newConnection();

        Channel channel = connection.createChannel();
        return channel;
    }
}
